package start.demo2learn;

/**
 * 汉诺塔问题
 */
public class Hanoi {
    static int nDisks=3;
    public static void main(String[] args){
        test(nDisks,'A','B','C');//A,B,C代表基座
    }
    public static void test(int topN,char from,char inter,char to){
        if(topN==1){
            System.out.println("Disk 1 from "+from+" to "+to);
        }else{
            test(topN-1,from,to,inter);
            System.out.println("Disk "+topN+" from "+from+" to "+to);
            test(topN-1,inter,from,to);
        }
    }
}
